import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const login = r => require.ensure([], () => r(require('@/page/login')), 'login');
const main = r => require.ensure([], () => r(require('@/page/main')), 'main');
const courseList = r => require.ensure([], () => r(require('@/page/course/courseList')), 'courseList');
const courseDetail = r => require.ensure([], () => r(require('@/page/course/courseDetail')), 'courseDetail');
const businessAdd = r => require.ensure([], () => r(require('@/page/business/businessAdd')), 'businessAdd');
const businessList = r => require.ensure([], () => r(require('@/page/business/businessList')), 'businessList');
const businessOne = r => require.ensure([], () => r(require('@/page/business/businessOne')), 'businessOne');
const businessTwo = r => require.ensure([], () => r(require('@/page/business/businessTwo')), 'businessTwo');
const businessThree= r => require.ensure([], () => r(require('@/page/business/businessThree')), 'businessThree');
const businessFour = r => require.ensure([], () => r(require('@/page/business/businessFour')), 'businessFour');
const businessFive = r => require.ensure([], () => r(require('@/page/business/businessFive')), 'businessFive');
const businessSix = r => require.ensure([], () => r(require('@/page/business/businessSix')), 'businessSix');
const businessSeven = r => require.ensure([], () => r(require('@/page/business/businessSeven')), 'businessSeven');
const businessEight = r => require.ensure([], () => r(require('@/page/business/businessEight')), 'businessEight');

const activityList = r => require.ensure([], () => r(require('@/page/activity/activityList')), 'activityList');
const activityAdd = r => require.ensure([], () => r(require('@/page/activity/activityAdd')), 'activityAdd');
const activityOne = r => require.ensure([], () => r(require('@/page/activity/activityOne')), 'activityOne');
const activityTwo = r => require.ensure([], () => r(require('@/page/activity/activityTwo')), 'activityTwo');
const activityThree = r => require.ensure([], () => r(require('@/page/activity/activityThree')), 'activityThree');
const activityFour = r => require.ensure([], () => r(require('@/page/activity/activityFour')), 'activityFour');
const activityFive = r => require.ensure([], () => r(require('@/page/activity/activityFive')), 'activityFive');
const activitySix = r => require.ensure([], () => r(require('@/page/activity/activitySix')), 'activitySix');

const tagEdit = r => require.ensure([], () => r(require('@/page/tag/tagEdit')), 'tagEdit');
const liudianEdit = r => require.ensure([], () => r(require('@/page/liudian/liudianEdit')), 'liudianEdit');
const packageEdit = r => require.ensure([], () => r(require('@/page/package/packageEdit')), 'packageEdit');

const sysUser = r => require.ensure([], () => r(require('@/page/sysUser/index')), 'sysUser');
const sysMenu = r => require.ensure([], () => r(require('@/page/sysMenu/index')), 'sysMenu');
const sysRole = r => require.ensure([], () => r(require('@/page/sysRole/index')), 'sysRole');

const routes = [{
		path: '/main',
		component: main,
		children: [
		{
			path: '/',
			component: courseList,
		},
		{
			path: '/courseDetail',
			component: courseDetail,
		},
		{
			path: '/businessAdd',
			component: businessAdd,
		},
		{
			path: '/businessOne',
			component: businessOne,
		},
		{
			path: '/businessTwo',
			component: businessTwo,
		},
		{
			path: '/businessThree',
			component: businessThree,
		},
		{
			path: '/businessFour',
			component: businessFour,
		},
		{
			path: '/businessFive',
			component: businessFive,
		},
		{
			path: '/businessSix',
			component: businessSix,
		},
		{
			path: '/businessSeven',
			component: businessSeven,
		},
		{
			path: '/businessEight',
			component: businessEight,
		},
		
		{
			path: '/businessList',
			component: businessList,
		},
		{
			path: '/activityList',
			component: activityList,
		},
		{
			path: '/activityAdd',
			component: activityAdd,
		},
		{
			path: '/activityOne',
			component: activityOne,
		},
		{
			path: '/activityTwo',
			component: activityTwo,
		},
		{
			path: '/activityThree',
			component: activityThree,
		},
		{
			path: '/activityFour',
			component: activityFour,
		},
		{
			path: '/activityFive',
			component: activityFive,
		},
		{
			path: '/activitySix',
			component: activitySix,
		},
		{
			path: '/tagEdit',
			component: tagEdit,
		},
		{
			path: '/liudianEdit',
			component: liudianEdit,
		},
		{
			path: '/packageEdit',
			component: packageEdit,
		},
		{
			path: '/user',
			component: sysUser,
		},
		{
			path: '/role',
			component: sysRole,
		},
		{
			path: '/menu',
			component: sysMenu,
		},
		
		]
	},
	{
		path: '/',
		component: login,

	},

]

export default new Router({
	mode: 'history',
	routes,
	strict: process.env.NODE_ENV !== 'production',
	//解决路由跳转滚动条没有回到顶部的问题
	scrollBehavior(to, from, savedPosition) {
		if(savedPosition) {
			return savedPosition
		} else {
			return {
				x: 0,
				y: 0
			}
		}
	},
})